<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>todolist</title>
</head>
<body>
    <h3>todolist</h3>
    <input type="text" id="todo"><button>清空列表</button>
    <div id="list">
        <h4>任务清单</h4>
    </div>
</body>
<script src="jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $("#todo").keypress(function (e) {
            if(e.keyCode == 13) {
                // console.log($("#todo").val());
                $("#list").append("<p>" + $("#todo").val() + "</p>");
                $("#todo").val("");
                $("#todo").focus();
            }
        })
        // 清除
        $("button").click(function(){
            // console.log(1);
            $("#list p").remove();
        })
    })
</script>
</html>